<template>
	<view class="page-container">
		<view class="headline-text">
			<image src="@/static/img/fh.png" @click="navBacke"></image>
			写字楼详情
		</view>
		<view class="banner">
			<swiper class="swiper" :autoplay="true" :interval="3000" :circular="true">
				<swiper-item class="swiper-item" v-for="(item,index) in imgList" :key="index">
					<image :src=" imagesUrl + item" mode="aspectFill" class="bImg"></image>
				</swiper-item>
			</swiper>
		</view>

		<view class="house-headline mtop">
			<view class="name">{{data.name}}</view>
			
			<view class="ul">
				<view class="li"><text>{{data.price}}</text>
				</view>
				<view class="li">{{data.area}}㎡<view>面积</view>
				</view>
				<view class="li">{{data.type}}<view>户型</view>
				</view>
			</view>
			
			<view>朝向：{{data.direction}}</view>
			<view>地址：{{data.address}}</view>
			
		</view>

		


		<view class="house-message m20 mtop">
			<view class="headline">
				<view :class="{ 'opt': (messageType == 0) }" @click="messageType=0">地址信息</view>
				<view :class="{ 'opt': (messageType == 1) }" @click="messageType=1">企业信息</view>
			</view>
			<!-- 地址信息 -->
			<view class="map" v-show="messageType == 0">
				<view class="map-box">
					<map ref="map" style="width: 100%;height: 300rpx;" :latitude=" data.map_x" :longitude="data.map_y">
					</map>
				</view>
			</view>
			
			<!-- 企业信息 -->
			<view class="firm" v-show="messageType == 1">
				<view class="ul">
					<view class="flex li">
						联系方式：<text>{{data.area}}</text>
					</view>
					<view class="flex li">
						官方网站：<text>{{data.area}}</text>
					</view>
					<view class="flex li">
						小程序二维码：<text>{{data.area}}</text>
					</view>
				</view>
			</view>
		</view>
		<!-- 	<view class="menu-top">
			<image src="@/static/img/bt.png" @click="navBacke"></image>
			<image src="@/static/img/sc.png"></image>
			<image src="@/static/img/f.png"></image>
		</view> -->
		<view class="menu-bottom">

			<view class="but-icon" @click="collect">
				<image src="@/static/img/xhh.png"></image>
				<!-- <image src="@/static/img/xh.png"></image> -->
				<view>收藏</view>
			</view>
			<view class="but">
				<view>电话咨询</view>
			</view>
			<view class="but">
				<view>前往查看</view>
			</view>
		</view>

	</view>
</template>

<script setup>
	import {
		ref,
		getCurrentInstance,
		defineProps,
	} from 'vue'
	import {
		onLoad,
		onShow,
		onShareAppMessage,
		onShareTimeline
	} from '@dcloudio/uni-app'
	const {
		proxy
	} = getCurrentInstance();

	//
	onLoad((e) => {
		id.value = props.id
		getHouse()
	})

	onShow(() => {

	})
	const imagesUrl = proxy.$imagesUrl; //图片路径

	const props = defineProps({ //获取跳转页面的数据
		id: {
			type: Number,
			required: true
		}
	});
	const id = ref(""); //房id
	const data = ref()
	const imgList = ref([]); //图片地址
	const messageType =ref(0);//信息展示类型 0-地址信息 1-企业信息

	function getHouse() {
		proxy.$request({
			url: `${proxy.$api.getHouse}`,
			method: "POST",
			data: {
				page: 1,
				limit: 10
			}
		}).then(res => {
			const a = res.data || [];
			data.value = a[0];
			imgList.value = data.value.url.split(",")
		})
	}


	function collect(){//收藏
		// proxy.$request({
		// 	url: `${proxy.$api.getHouse}`,
		// 	method: "POST",
		// 	data: {
		// 		page: 1,
		// 		limit: 10
		// 	}
		// }).then(res => {
		// 	const a = res.data || [];
		// 	data.value = a[0];
		// 	console.log(data.value);
		// 	imgList.value = data.value.url.split(",")
		// })
	}

	function navBacke() {
		uni.navigateBack({
			delta: 1,
			success: function(res) {},
			fail: function() {
				uni.switchTab({
					url: '/pages/index/index' // 指定页面的路径
				});
			}
		})
	}
</script>

<style lang="less" scoped>
	.page-container {
		background: white;
		// padding-top: ;
		padding-bottom: 120rpx;
	}
	
	.headline-text{
		width: 100%;
		height: 50rpx;
		text-align: center;
		image{
			position: absolute;
			left: 30rpx;
			width: 32rpx;
			height: 32rpx;
		}
	}

	.mtop {
		margin-top: 60rpx;
	}

	.menu-top {
		position: fixed;
		top: 0;
		width: 100%;
		height: 100rpx;

		image {
			background-color: #BBBBBB;
			border-radius: 50%;
			padding: 10rpx;
			width: 40rpx;
			height: 40rpx;
			margin-top: 20rpx;
			position: absolute;
		}

		image:nth-child(1) {
			left: 30rpx;
		}

		image:nth-child(2) {
			right: 90rpx;
		}

		image:nth-child(3) {
			right: 20rpx;
		}
	}

	.menu-bottom {
		display: flex;
		align-items: center;
		justify-content: center;
		position: fixed;
		bottom: 0rpx;
		width: 100%;
		height: 120rpx;
		background-color: #F7F7F7;

		.but-icon{
			// margin-right: 20rpx;
			image{
				width: 35rpx;
				height: 35rpx;
			}
			text-align: center;
			font-size: 20rpx;
		}

		.but {
			width: 36%;
			margin-left: 40rpx;
			text-align: center;
			background-color: #EEEEEE;
			padding: 15rpx;
			border-radius: 30rpx;
		}
	}


	.m20 {
		margin-left: 20px;
		margin-right: 20px;
	}



	.banner {
		width: calc(100%);
		height: 420rpx;
		overflow: hidden;
		// margin: 20rpx;
		// border-radius: 30rpx;

		.swiper {
			width: 100%;
			height: 100%;

			.swiper-item {
				width: 100%;
				height: 100%;
			}
		}

		.bImg {
			width: 100%;
			height: 100%;
			display: block;
		}
	}

	.house-headline {
		position: relative;
		width: calc(100% - 80rpx);
		top: -100rpx;
		margin: 40rpx;
		border: solid 1rpx #BBBBBB;
		border-radius: 40rpx;
		background-color: white;
		padding: 20rpx;
		padding-top: 30rpx;
		padding-bottom: 40rpx;
		font-size: 30rpx;
		.ul {
			height: 180rpx;
			text-align: center;
			display: flex;
			align-items: center;
			justify-content: center;
			.li {
				width: 30%;
				text{
					color: #FF0000;
				}
				view {
					margin-top: 20rpx;
				}
			}
		}
	}

	.house-message {
		width: calc(100% - 80rpx);
		top: -100rpx;
		margin: 40rpx;
		margin-top: -100rpx ;
		border: solid 1rpx #BBBBBB;
		border-radius: 40rpx;
		background-color: white;
		padding: 20rpx;
		padding-top: 30rpx;
		padding-bottom: 40rpx;
		font-size: 30rpx;
		.headline {
			display: flex;
			height: 45rpx;
			margin-bottom: 20rpx;
			view{
				margin-right: 20rpx;
				padding-bottom: 20rpx;
				line-height: 35rpx;
			}
			.opt{
				color: #2A8FFC;
				border-bottom: solid 2rpx #2A8FFC;
			}
			
		}
		.firm{
			.ul {
				width: calc(100% - 80rpx);
				height: 300rpx;
				.li{
					margin-bottom: 30rpx;
				}
			}
		}

	}

	.house-map {

		.map-box {
			margin-top: 20rpx;
		}
	}

	.house-firm {
		.ul {
			margin-top: 30rpx;
			margin-right: 10rpx;

			.li {

				margin-bottom: 30rpx;

				text {
					margin-left: 10rpx;
				}
			}
		}
	}
</style>
